<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="com.webapp.model.Circle, java.util.List" %>
<% 
	Circle theCircle = (Circle)session.getAttribute("Circle");
	List theFriends = (List)session.getAttribute("Friends");
	System.out.print(theCircle);
	if(theCircle == null)
		response.sendRedirect("Error.jsp");
%>    
<!-- include moo talk header file -->
<%@ include file="MooTalkHeader.jsp" %>

		<div id="site_content_text">
		<% 
				String x = request.getParameter("viewFriends"); 
				if(x != null) {
					
					if(x.equals("circledited")) {
						%>
							<p style="color:red;">
								Circle was updated!
							</p>
						<%
					}
					
					if(x.equals("added")) {
						%>
							<p style="color:red;">
								Your fence was built! Please have a great day!
							</p>
						<%
					}
					
					if(x.equals("friendadded")) {
						%>
							<p style="color:red;">
								Your Friend was added!
							</p>
						<%
					}
					
					if(x.equals("friendnotadded")) {
						%>
							<p style="color:red;">
								The friend could not be added because they don't exist or in your fence!
							</p>
						<%
					}
					
					if(x.equals("error")) {
						%>
							<p style="color:red;">
								There was an error updating your circle!
							</p>
						<%
					}
					
					if(x.equals("friendnotremoved")) {
						%>
							<p style="color:red;">
								Friend wasn't removed!
							</p>
						<%
					}
					
					if(x.equals("friendremoved")) {
						%>
							<p style="color:red;">
								Friend was removed!
							</p>
						<%
					}
				} 
			%>
			<h2>Fence Information</h2>
			<form id="editCircle" name="editCircle" action="EditCircle.do" method="post">
				<span><strong>Fence ID:</strong></span> <%=theCircle.getCircleId()%> </h2><br/>
				<span><strong>Fence Name: </strong></span> <input type="text" name="fenceNameTxt" value="<%=theCircle.getCircleName()%>"/><br/>
				<span><strong>Fence Type: </strong></span> <input type="text" name="fenceTypeTxt" value="<%=theCircle.getCircleType()%>"/><br/>
				<input type="hidden" name="fenceIdTxt" value="<%=theCircle.getCircleId()%>"/>
				<input class="btn" type="submit" value="Edit Fence Name!"/>
			</form>
			<form name="viewPost" action="GetPostUser.do" method="post">
				<input type="hidden" name="fenceIdTxt" value="<%=theCircle.getCircleId()%>"/>
				<input class="btn" type="submit" value="View Moos!"/>
			</form>
			<form action="PostEditView.jsp">
				<input class="btn" type="submit" value="New Moos!"/>
			</form>
			<form action="RemoveCircle.do" method="post">
				<input type="hidden" name="fenceIdTxt" value="<%=theCircle.getCircleId()%>"/>
				<input type="hidden" name="circleNameTxt" value="<%=theCircle.getCircleName()%>"/>
				<input class="btn" type="submit" value="Remove this Fence!"/>
			</form>
			<br/>
			<hr/>
			<br/>
			<!--  grid type layout -->
			<h2>Friends Herded Up!</h2>
			<% if(theFriends != null || !theFriends.equals("") || theFriends.get(0) != null || !theFriends.get(0).equals("")) { %>
				<% for(int i = 0; i < theFriends.size(); i++) { %>
					<% if( i%2 == 0)  { %>
						<div class="even">
					<% } else if ( i%2 == 1) {  %>
						<div class="odd">
					<% } %>
					<%=theFriends.get(i)%> herded!
					</div>
				<% } %>
			<% } else { %>
				<p> You have no friends! Herd some up!</p>
			<% } %>
			<br/>
			<hr/>
			<br/>
			<form id="fenceFriend" name="fenceFriend" action="FindFriend.do" method="post">
				<h2>Find a Friend to Fence in!</h2>
				<span><strong>Friend ID: </strong></span><input type="text" name="friendIDTxt"/><br/>
				<input type="hidden" name="fenceIDTxt" value="<%=theCircle.getCircleId()%>"/></p>
				<input type="submit" class="btn" value="Round Up Friend!"/>
			</form>
			<br/>
			<hr/>
			<br/>
			<form id="removeFriend" name="removeFriend" action="RemoveFriend.do" method="post">
				<h2>Round Up and Remove Friend in this Fence!</h2>
				<span><strong>Friend ID: </strong></span><input type="text" name="friendIDTxt"/><br/>
				<input type="hidden" name="fenceIDTxt" value="<%=theCircle.getCircleId()%>"/>
				<input type="submit" class="btn" value="Throw'em out!"/>
			</form>
		</div>
		
<!--  include moo talk footer file -->
<%@ include file="MooTalkFooter.jsp" %>
